﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Honestysoft.Baseframework.WebUI;
using System.Data;

namespace Honestysoft.Financing.WebUI.Module.Attach
{
    public partial class ContractFileCabinet_List : BasePage
    {
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);
            if (!IsPostBack)
            {
                AspNetPager1.PageSize = Globals.PageSize;
                BindControl();
                Bind();
            }
        }
        /// <summary>
        /// 绑定页面控件。
        /// </summary>
        private void BindControl()
        {
            ControlHelper.BindDictionary(ddlProjectCategory, "ProjectCategory");
            ControlHelper.InsertAllItemAndSelect(ref ddlProjectCategory);
        }

        /// <summary>
        /// 设置弹出窗体大小
        /// 基类中已自动做控制。默认宽度800，高度600
        /// </summary>
        protected override void SetDialogSize()
        {
            //base.SetDialogSize();
            //重载宽度，高度
            //ModalDialogSize.EditHeight = 600;
            //ModalDialogSize.EditWidth = 720;
            //ModalDialogSize.ViewHeight = 600;
            //ModalDialogSize.ViewWidth = 720;
        }
        /// <summary>
        /// 根据权限控制页面按钮.
        /// 基类中已自动做控制。
        /// </summary>
        protected override void ButtonSetting()
        {
            //base.ButtonSetting();
            ////使用PageSecurity检查权限
            //if (PageSecurity.Add)
            //{
            //    btnAdd.Attributes.Add("onclick", "javascript:openDialog('" + Globals.Home + "Module/Project/Project_Edit.aspx?FunctionID=" + FunctionID + "'," + ModalDialogSize.EditWidth + ", " + ModalDialogSize.EditHeight + ", '新增项目信息');return false;");
            //}
        }
        private void Bind()
        {
            string owner971 = "";
            if (ddlProjectCategory.SelectedValue != "0")
            {
                owner971 = ddlProjectCategory.SelectedValue;
            }
            int recordCount = 0, pageCount = 0;
            DataTable dt = new Honestysoft.Financing.BusinessLogic.Attach(Globals.CurrentConnStringName).GetContractFileCabinet(owner971, txtProjectSN.Text.Trim(), txtProjectName.Text.Trim(),txtContractName.Text.Trim(), AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex, out pageCount, out recordCount);
            AspNetPager1.RecordCount = recordCount;
            rptList.DataSource = dt;
            rptList.DataBind();
        }

        protected string GetButtonScript(string dateId)
        {
            return "";
        }
        
        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            Bind();
        }

        protected void btnQuery_Click(object sender, EventArgs e)
        {
            Bind();
        }
    }
}